<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,minimum-scale=1, user-scalable=no">
		<title>解构赋值</title>
		<script type="text/javascript">
			//函数参数解构赋值
			function cal({n,m,op}){
				switch (op) {
					case '+': {
						return n + m
					}
					case '-': {
						return n - m
					}
					case '*': {
						return n * m
					}
					case '/': {
						return n / m
					}
				}
			}
			//let { n, m, op } = { n: 1, m: 2, op: '+' }
			console.log(cal({ n: 1, m: 2, op: '+' }))
			
			function getArr(){
				return [1,2,3]
			}
			let [a,b,c] = getArr()
			console.log(a,b,c)
			
			 //有序的参数
			function add([a = 0, b, c]) {
			      console.log(a + b + c)
			    }
				
			add([, 2, 3])
		</script>
	</head>
	<body>
		<div id="app">
			<!-- todo -->
		</div>
	</body>
</html>
